<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<h1 style="text-align: center">文件服务</h1>
<br>
<div>
    <a href="/">首页</a>
</div>

<br><br>
<div th:if="${message}" style="margin-left: 10%">
    <h2 th:text="${message}"/>
</div>

<br>
<div>
    <form method="POST" enctype="multipart/form-data" action="/">
        <table>
            <tr>
                <td>上传文件:</td>
                <td><input type="file" name="file"/></td>
                <td><input type="submit" value="上传"/></td>
            </tr>
        </table>

    </form>
</div>
<br><br>

<div style="margin-left: 5%">
    <h3 style="text-align: center">文件列表</h3>
    <table border="1">
        <thead>
        <tr style="background-color: beige">
            <td>文件名</td>
            <td>文件ID</td>
            <td>contentType</td>
            <td>文件大小</td>
            <td>上传时间</td>
            <td>md5</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        <tr th:if="${files.size()} eq 0">
            <td colspan="3">没有文件信息！！</td>
        </tr>
        <tr th:each="file : ${files}">
            <td><a th:href="'files/'+${file.id}" th:text="${file.name}"/></td>
            <td th:text="${file.id}"></td>
            <td th:text="${file.contentType}"></td>
            <td th:text="${file.size}"></td>
            <td th:text="${#dates.format(file.uploadDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
            <td th:text="${file.md5}"></td>
            <td><a target="_blank" th:href="@{/view(id=${file.id})}">预览</a>|<a
                    th:href="@{/delete(id=${file.id})}">删除</a></td>
        </tr>
        </tbody>
    </table>
</div>

</body>

<style>
    body {
        text-align: center;
    }

    table {
        margin: auto;
    }

</style>
